package com.example.springboot.mapper;
import com.example.springboot.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper

public interface UserMapper {
    @Insert("insert into `user` (username,password,email,address,avatar,role) values " +
            "(#{username},#{password},#{email},#{address},#{avatar},#{role})")
    void insert(User user);

    @Update("update `user` set username =#{username},password=#{password}," +
            "email =#{email},address =#{address},avatar =#{avatar} ,role =#{role} where id = #{id}")
    void update(User user);

    @Delete("delete from `user` where id = #{id}")
    void delete(User user);

    @Select("select *from `user` order by id desc")
    List<User> selectAll();

    @Select(("select * from `user` where id = #{id} order by id desc"))
    User selectById(Integer id);

    @Select(("select * from `user` where username = #{username} order by id desc"))
    User selectByName(String username);


}

